﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage" %>

<%@ Import Namespace="WebHoiChoMuaBan.Controllers.Helpers" %>
<%@ Import Namespace="WebHoiChoMuaBan.Controllers.Utility" %>
<%@ Import Namespace="WebHoiChoMuaBan.Models" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Photo
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <style type="text/css">
        .Pagging
        {
            float :left;
        }
        .ButtonFunction
        {
            width : 90px;
        }
        
        table td a
        {
            text-decoration : underline !important;
        }
    </style>
    <div class="ButtonFunction">
        <div class="private_button_upload col_left hoicho_margin_leftright">
            <img src="/../Content/Images/add.jpg" alt="" />   
            <a href="#">Sửa</a>
        </div>
        <div class="private_button_upload col_left hoicho_margin_leftright">
            <img src="/../Content/Images/add.jpg" alt="" />   
            <a href="#">Xóa</a>
        </div>
    </div>
    
    <div class="Pagging">
                <%
                    PhotoHelper.FetchPhotoResult lstPhoto = (PhotoHelper.FetchPhotoResult)ViewData["ListPhotos"];
                    int i, p;
                    if (Request.QueryString["p"] == null && !int.TryParse(Request.QueryString["p"], out p))
                    //if(p!=0)
                    {
                        p = 1;
                    }
                    else p = int.Parse(Request.QueryString["p"]);
                     %>
                <% if (p > 1)
                   { %><a href='<%=string.Format("{0}?p={1}'",
                                                        Url.Action("Index", "AdminPhoto"),
                                                        p-1) %>'><img src="/../Content/Images/arrow_breakpage_left.gif" alt="">&nbsp;Trang trước</a> <% } %>
                <%
                   if (p > 3)
                       Response.Write(string.Format("<a href='{0}?p={1}'{2}>{3}</a> ",
                                                       Url.Action("Index", "AdminPhoto"),
                                                       1,
                                                       string.Empty,
                                                        1));
                   if (p > 4)
                       Response.Write("...");
                   int total = lstPhoto.totalPages;
                   int from = (p - 2 < 1 ? 1 : p - 2);
                   int to = (p + 2 >= total ? total : p + 2);
                   for (i = from; i <= to; i++)
                       Response.Write(string.Format("<a href='{0}?p={1}'{2}>{3}</a> ",
                                                       Url.Action("Index", "AdminPhoto"),
                                                       i,
                                                       (i == p ? "class='menu_select'" : string.Empty),
                                                        i));
                   if (p <= total - 4)
                       Response.Write("...");
                   if (p <= total - 3)
                       Response.Write(string.Format("<a href='{0}?p={1}'{2}>{3}</a> ",
                                                       Url.Action("Index", "AdminPhoto"),
                                                       total,
                                                       string.Empty,
                                                       total));
                 %>
            
                <% if (p < lstPhoto.totalPages)
                   { %><a href='<%=string.Format("{0}?p={1}'",
                                                        Url.Action("Index", "AdminPhoto"),
                                                        p+1) %>'>Trang sau&nbsp;<img src="/../Content/Images/arrow_breakpage_right.gif" alt=""></a> <% } %>
            
    </div>
    <div style="clear:both">&nbsp;</div>
                
            <% 
            if (lstPhoto.photos.Count > 0)
            { 
            %>
    <table border="0" cellpadding="2" cellspacing = "0" width="100%">
            <tr>
                <td width="2%"><input id="Checkbox3" type="checkbox" /></td>
                <td width="3%">&nbsp;</td>
                <td width="60%">Nội dung</td>
                <td width="15%">Người đăng</td>
                <td width="8%">
                    <div class="CustomButton btnDelete">
                        <img src="/../Content/Images/add.jpg" alt="" />   
                        Xóa
                    </div>
                </td>
                <td width="6%">Link</td>
                <td width="9%">Ngày gửi</td>
            </tr>
            <% 
                foreach (var item in lstPhoto.photos)
                {
            %>
            <tr>
                <td><input id="Checkbox2" type="checkbox" /></td>
                <td>
                    <img src="/../Content/Images/envelop.png" alt=""/></td>
                    <%--<div class="Header"><%= item.PhotoTitle%></div>--%>
                    <td><div class="Description"><%= item.PhotoTitle%></div></td>
                <td>
                    <div class="Header"><%= item.PhotoAlbum.Member.MemUsername%></div>
                </td>
                <td>
                    <div class="CustomButton btnDelete">
                        <img src="/../Content/Images/add.jpg" alt="" />   
                        <%--<a href="#">Xóa</a>--%>
                        <%= Html.ActionLink("Xóa", "DeletePhoto", "AdminPhoto", new { photoId  = item.PhotoId, p=p},null)%>
                    </div>
                </td>
                <td><a href="#" class="Header">Link</a></td>
                <td>
                    <span class="Header"><%= item.PhotoPostDate.ToString("dd/MM/yyyy") %></span>
                </td>
            </tr>
            <%
                }
            } %>
            <%--<tr class="DongChan">
                <td><input id="Checkbox1" type="checkbox" /></td>
                <td width="10px"><img src="/../Content/Images/envelop.png" alt=""/></td>
                <td width="">
                    <div class="Header">Nguyễn Văn Hai</div>
                    <div class="Description">Trẻ trung với những gam màu tươi tắn của mùa hè. Triệu Vy hấp dẫn bạn trai sắp cưới của bạn</div>
                </td>
                <td>
                    <div class="Header">minhtri</div>
                </td>
                <td>
                    <div class="CustomButton btnDelete">
                        <img src="/../Content/Images/add.jpg" alt="" />   
                        <a href="#">Xóa</a>
                    </div>
                </td>
                <td><a href="#" class="Header">Link</a></td>
                <td>
                    <span class="Header">21/07/2011</span>
                </td>
            </tr>--%>
        </table>
        <div class="ButtonFunction">
        <div class="CustomButton btnEdit">
            <img src="/../Content/Images/add.jpg" alt="" />   
            <a href="#">Sửa</a>
        </div>
        <div class="CustomButton btnDelete">
            <img src="/../Content/Images/add.jpg" alt="" />   
            <a href="#">Xóa</a>
        </div>
    </div>
    <div class="Pagging">
                <%
                    if (Request.QueryString["p"] == null && !int.TryParse(Request.QueryString["p"], out p))
                    //if(p!=0)
                    {
                        p = 1;
                    }
                    else p = int.Parse(Request.QueryString["p"]);
                     %>
                <% if (p > 1)
                   { %><a href='<%=string.Format("{0}?p={1}'",
                                                        Url.Action("Index", "AdminPhoto"),
                                                        p-1) %>'><img src="/../Content/Images/arrow_breakpage_left.gif" alt="">&nbsp;Trang trước</a> <% } %>
                <%
                   if (p > 3)
                       Response.Write(string.Format("<a href='{0}?p={1}'{2}>{3}</a> ",
                                                       Url.Action("Index", "AdminPhoto"),
                                                       1,
                                                       string.Empty,
                                                        1));
                   if (p > 4)
                       Response.Write("...");
                   total = lstPhoto.totalPages;
                   from = (p - 2 < 1 ? 1 : p - 2);
                   to = (p + 2 >= total ? total : p + 2);
                   for (i = from; i <= to; i++)
                       Response.Write(string.Format("<a href='{0}?p={1}'{2}>{3}</a> ",
                                                       Url.Action("Index", "AdminPhoto"),
                                                       i,
                                                       (i == p ? "class='menu_select'" : string.Empty),
                                                        i));
                   if (p <= total - 4)
                       Response.Write("...");
                   if (p <= total - 3)
                       Response.Write(string.Format("<a href='{0}?p={1}'{2}>{3}</a> ",
                                                       Url.Action("Index", "AdminPhoto"),
                                                       total,
                                                       string.Empty,
                                                       total));
                 %>
            
                <% if (p < lstPhoto.totalPages)
                   { %><a href='<%=string.Format("{0}?p={1}'",
                                                        Url.Action("Index", "AdminPhoto"),
                                                        p+1) %>'>Trang sau&nbsp;<img src="/../Content/Images/arrow_breakpage_right.gif" alt=""></a> <% } %>
            
    </div>
</asp:Content>
